<?php
!function_exists('readover') && exit('Forbidden');

$a_sql=$u ? "uid='$u'" : "username='$a'";
$query=$db->query("SELECT uid as u FROM pw_members WHERE $a_sql");
if($db->num_rows($query)==1){
	$u_db=$db->fetch_array($query);
	$u=$u_db['u'];
	if($uid!=$u){
		$query=$db->query("SELECT adsips FROM pw_memberinfo WHERE uid='$u'");
		if($db->num_rows($query)==1){
			$u_db=$db->fetch_array($query);
			if(strpos($u_db['adsips'],$onlineip)===false){
				$adsips=$u_db['adsips']."\t".$onlineip;
				$db->update("UPDATE pw_memberinfo SET adsips='$adsips' WHERE uid='$u'");
				$db->update("UPDATE pw_members SET credit=credit+1 WHERE uid='$u'");
			}
		}else{
			$db->update("INSERT INTO pw_memberinfo(uid,adsips) VALUES('$u','$onlineip')");
		}
	}
}
?>